var app = getApp();
Page(Object.assign({},{
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        page : {
            isend : false,
            doing : false,
            doo : 'admin',
            pdata : {
                op : 'hexiaolog',
                page : 1,
                status : 0,
                init : 1,
                search : '',
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
        isIPX : app.globalData.isIPX ? 1 : 0,
		hxlog : {},
        allshop : [],
    },
    onShow:function(options){
        var self = this;
        
        self.setData({
            'page.pdata.page' : 1,
            'page.pdata.init' : 1,
            'page.isend' : false,
        })
        
        app.com.auth(function(user){
            app.com.getPage(self,self.data.page,0,function(res){
                var data = res.data.data;
                self.setData({
                    datalist : data.list,
                    params : data.params,
                    hxlog : data.hxlog,
                    allshop : data.fendian ? data.fendian : [],
                    'page.pdata.init' : 0,
                    inited : true,
                });

                wx.setNavigationBarTitle({
                    title: res.data.data.params.hxbname+'记录',
                });
                
            },false,function(res){
                app.com.alert( res.data.message,function(){
                    if( res.data.errno == 2 ){
                        app.globalData.adminurl = app.com.getUrlArgs();
                        wx.navigateTo({
                            url : res.data.data.url
                        });
                    }
                });
            });

        });
        
    },
    onReachBottom : function(){
        var self = this;

        app.com.getPage(self,self.data.page,0,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.data.isdown = true;
        
        this.onShow( this.data.options );
        this.data.isdown = false;
        wx.stopPullDownRefresh();
    },
    onSearch(e){
        var self = this;
        self.data.page.pdata.search = e.detail;
        self.setData({
            datalist : [],
            'page.pdata.page' : 1,
            'page.pdata.init' : 1,
            'page.isend' : false,
            'page.waitf' : 0,
            'page.nodataf' : 0
        });
        app.com.getPage(self,self.data.page,0,function(res){
            self.setData({
                datalist : res.data.data.list,
                hxlog : res.data.data.hxlog,
            });
        });
    },
    onChanges(e){
        var d = {
            detail : '',
        }
        this.onSearch(d);
    },
    tab(e){
        var self = this;
        var id = e.detail.name;
        if( self.data.ising || id == self.data.page.pdata.fendianid ) return false;
        self.data.ising = true;
        
        self.setData({
            datalist : [],
            'page.pdata.fendianid' : id,
            'page.pdata.init' : 1,
            'page.pdata.page' : 1,
            'page.isend' : false,
            'page.waitf' : 0,
            'page.nodataf' : 0
        });
        app.com.getPage(self,self.data.page,0,function(res){
            self.setData({
                datalist : res.data.data.list,
                hxlog : res.data.data.hxlog,
                'page.pdata.init' : 0,
            });
        });
        self.data.ising = false;
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    }
}))